package com.company.LKCompetition;

public class Main {
    public static void main(String[] args) {
        int[] nums = {1,2,3,4,5};
        coutPairs(nums,2);
    }
    public static long coutPairs(int[] nums, int k) {
        long num = 0;
        int n = nums.length;
        int[] arr = new int[100001];
        for(int i = 0;i<nums.length;i++){
            arr[nums[i]]++;
        }
        for(int i = 0;i<n;i++){
            if(nums[i]%k==0){
                num += n-1;
            }else{
                num += arr[k%nums[i]];
            }
        }
        return num;
    }
}
